package com.application.moneycalculator.activity;

import com.application.moneycalculator.data.DBLoader;
import com.application.moneycalculator.data.DBParser.ParserCode;
import com.application.moneycalculator.data.ExpensesCollection;
import com.application.moneycalculator.log.Log_;

import android.os.Bundle;
import android.widget.ListView;
import android.widget.ProgressBar;

abstract public class ListExpensesActivity extends BaseActivity implements DBLoader{
	
	private final String TAG = "ListExpensesActivity";
	
    /** Called when the activity is first created. */
	protected ListView listExpenses;
	protected ProgressBar mProgress;
	
	abstract protected void createListObject();
	abstract protected void createProgressBar();
	
	protected ListView getListView()
	{
		return listExpenses;
	}
	
	public ProgressBar getProgressBar()
	{
		return mProgress;
	}
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	Log_.out(TAG, "onCreate start");
    	
        super.onCreate(savedInstanceState);
        
        createListObject();
        createProgressBar();
        
        Log_.out(TAG, "onCreate finish");
    }

	@Override
	public void loaded(ExpensesCollection collection, ParserCode errorCode) {
		Log_.out(TAG, "DB is loaded, error code [" + errorCode + "]");
		
		if(errorCode == ParserCode.PARSER_CODE_SUCESS)
		{
			//SUCCESS
			if(getListView() != null)
			{
				getListView().removeAllViews();
				for(int i = 0; i < collection.getCount(); i++)
				{
					//getListView().add
				}
			}
		}
		else
		{
		}
		
	}
}